/*** Eclipse Class Decompiler plugin, copyright (c) 2012 Chao Chen (cnfree2000@hotmail.com) ***/
package com.feiyue.basic.reader.util;

import com.feiyue.basic.reader.pojo.FileInfo;
import java.text.Collator;
import java.util.*;

public class CompareUtil
{
	static class SizeComparator
		implements Comparator
	{

		public int compare(Object obj, Object obj1)
		{
			long l = ((FileInfo)obj).getSize();
			long l1 = ((FileInfo)obj1).getSize();
			int i;
			if (l - l1 > 0L)
				i = 1;
			else
			if (l - l1 < 0L)
				i = -1;
			else
				i = 0;
			return i;
		}
	}

	static class TimeComparator
		implements Comparator
	{

		public int compare(Object obj, Object obj1)
		{
			long l = ((FileInfo)obj).getDate().getTime();
			long l1 = ((FileInfo)obj1).getDate().getTime();
			int i;
			if (l - l1 > 0L)
				i = 1;
			else
			if (l - l1 < 0L)
				i = -1;
			else
				i = 0;
			return i;
		}
	}

	//TODO 有问题
//	public static List compareName(List list)
//	{
//		ArrayList arraylist;
//		String as[];
//		int j;
//		arraylist = new ArrayList();
//		as = new String[list.size()];
//		int i = 0;
//		
//		while (i < list.size()) {
//			as[i] = ((FileInfo)list.get(i)).getName();
//			i++;
//		}
//		Arrays.sort(as, Collator.getInstance(Locale.CHINA));
//		j = 0;
//		
//		while (j < as.length) {
//			int k = 0;
//			
//			while (k < list.size()) {
//				if (as[j].equalsIgnoreCase(((FileInfo)list.get(k)).getName()))
//					arraylist.add((FileInfo)list.get(k));
//				k++;
//			}
//		}
//		
//		return arraylist;
//	}

//	public static List compareSize(List list)
//	{
//		ArrayList arraylist = new ArrayList();
//		FileInfo[]  = new FileInfo[list.size()];
//		FileInfo afileinfo[] = (FileInfo[])list.toArray(new FileInfo[list.size()]);
//		Arrays.sort(afileinfo, new SizeComparator());
//		int i = afileinfo.length;
//		int j = 0;
//		do
//		{
//			if (j >= i)
//				return arraylist;
//			arraylist.add(afileinfo[j]);
//			j++;
//		} while (true);
//	}

//	public static List compareTime(List list)
//	{
//		ArrayList arraylist = new ArrayList();
//		FileInfo[]  = new FileInfo[list.size()];
//		FileInfo afileinfo[] = (FileInfo[])list.toArray(new FileInfo[list.size()]);
//		Arrays.sort(afileinfo, new TimeComparator());
//		int i = afileinfo.length;
//		int j = 0;
//		do
//		{
//			if (j >= i)
//				return arraylist;
//			arraylist.add(afileinfo[j]);
//			j++;
//		} while (true);
//	}

//	public static List compareType(List list)
//	{
//		ArrayList arraylist;
//		Iterator iterator;
//		arraylist = new ArrayList();
//		iterator = list.iterator();
//_L7:
//		if (iterator.hasNext()) goto _L2; else goto _L1
//_L1:
//		Iterator iterator1 = list.iterator();
//_L8:
//		if (iterator1.hasNext()) goto _L4; else goto _L3
//_L3:
//		Iterator iterator2 = list.iterator();
//_L9:
//		if (iterator2.hasNext()) goto _L6; else goto _L5
//_L5:
//		Iterator iterator3 = list.iterator();
//_L10:
//		if (!iterator3.hasNext())
//			return arraylist;
//		break MISSING_BLOCK_LABEL_187;
//_L2:
//		FileInfo fileinfo = (FileInfo)iterator.next();
//		if (fileinfo.getType().equalsIgnoreCase("folder"))
//			arraylist.add(fileinfo);
//		  goto _L7
//_L4:
//		FileInfo fileinfo1 = (FileInfo)iterator1.next();
//		if (fileinfo1.getType().equalsIgnoreCase("rar"))
//			arraylist.add(fileinfo1);
//		  goto _L8
//_L6:
//		FileInfo fileinfo2 = (FileInfo)iterator2.next();
//		if (fileinfo2.getType().equalsIgnoreCase("apk"))
//			arraylist.add(fileinfo2);
//		  goto _L9
//		FileInfo fileinfo3 = (FileInfo)iterator3.next();
//		if (fileinfo3.getType().equalsIgnoreCase("file"))
//			arraylist.add(fileinfo3);
//		  goto _L10
//	}
}